﻿namespace MicroCloud.Entity
{
    /// <summary>
    /// 实体管理器
    /// </summary>
    public interface IEntityManager
    {
        /// <summary>
        /// 初始化实体类型注册
        /// </summary>
        void Initialize();

        /// <summary>
        /// 获取指定上下文类型的实体配置注册信息
        /// </summary>
        /// <param name="dbContextType">数据上下文类型</param>
        /// <returns></returns>
        IEntityRegister[] GetEntityRegisters(Type dbContextType);

        /// <summary>
        /// 获取实体类所属的数据上下文类型
        /// </summary>
        /// <param name="entityType">实体类型</param>
        /// <returns>数据上下文类型</returns>
        Type GetDbContextTypeForEntity(Type entityType);

        /// <summary>
        /// 获取已注册实体类型集合
        /// </summary>
        /// <param name="predicate">条件过滤表达式</param>
        /// <returns>实体类型集合</returns>
        /// <exception cref="Exception"></exception>
        Type[] GetEntityTypes(Func<Type, bool> predicate = null);

    }
}